<ui:composition template="/template/LayoutPadrao.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core">

	<ui:define name="titulo">#{msg.people}</ui:define>
	<ui:define name="conteudo">

		<h1>#{msg.people}</h1>
		<h:form>
			<h:commandButton value="#{msg.newPerson}"
				action="NovaPessoa?faces-redirect=true"
				rendered="#{request.isUserInRole('cadastro')}" />
		</h:form>

		<h:form id="frm">
			<h:messages showDetail="false" showSummary="true"
				styleClass="form-messages" errorClass="error" infoClass="info" />
			<h:dataTable styleClass="grid" var="pessoa"
				value="#{consultaPessoaBean.pessoas}" headerClass="cabecalho"
				rowClasses="cor-sim, cor-nao">
				<h:column>
					<f:facet name="header">
					#{msg.name}
				</f:facet>
					<h:outputText value="#{pessoa.nome}" />
				</h:column>
				<h:column>
					<f:facet name="header">
					#{msg.type}
				</f:facet>
					<h:outputText value="#{pessoa.tipo.descricao}" />
				</h:column>
				<h:column>
					<f:facet name="header">
					#{msg.activityField}
				</f:facet>
					<h:outputText value="#{pessoa.ramo.descricao}" />
				</h:column>
				<h:column rendered="#{request.isUserInRole('cadastro')}">
					<h:link outcome="NovaPessoa">
						<h:graphicImage value="/imagens/editar.png" />
						<f:param value="#{pessoa.codigo}" name="codigo" />
					</h:link>
					<h:commandLink action="#{consultaPessoaBean.excluir}">
						<h:graphicImage value="/imagens/excluir.png" />
						<f:setPropertyActionListener
							target="#{consultaPessoaBean.pessoaSelecionada}"
							value="#{pessoa}" />
						<f:ajax render="@form" />
					</h:commandLink>
				</h:column>
			</h:dataTable>
		</h:form>

	</ui:define>

</ui:composition>

